package com.hengda.smart.speak.d.stc;

import android.content.Context;


import com.hengda.smart.speak.d.App;
import com.hengda.smart.speak.d.config.AppConfig;
import com.hengda.smart.speak.d.util.CommonUtil;
import com.hengda.smart.speak.d.util.SharePreferenceUtil;

import java.io.IOException;
import java.io.OutputStream;
import java.security.InvalidParameterException;


/**
 *   STC工具
 */


public class StcLauncher {



	private OutputStream stcOutputStream;
	private SharePreferenceUtil spUitl;


	private byte hostNumberH;
	private byte hostNumberL;

	private byte volumeByte;

	/**
	 * <p>Title: </p>
	 * <p>Description: 构造器</p>
	 * @author wzq
	 * @date 2015-6-11 下午3:26:54
	 * @update (date)
	 */
	public StcLauncher(App application, Context context) {
		try {
			this.stcOutputStream = application.getSerialPort()
					.getOutputStream();
			spUitl=new SharePreferenceUtil(context, AppConfig.SHARE_NAME);
		} catch (InvalidParameterException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}


	/**
	 *
	 * @Description:
	 * 打开音频模块，打开人工讲解AudioHardware有两个内部类，
	 * AudioStreamOutALSA和AudioStreamInALSA，我们要解决的是声音播放的问题， 看AudioStreamOutALSA即可。 AudioStreamOutALSA代码很清晰，很快找到了我们需要的代码，写PCM数据用的函数：
	 * @param hostNO
	 * @param volume
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:27:59
	 * @update (date)
	 */
	public void openAudio(int hostNO,int volume) {
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x20 ;
		command[3]= CommonUtil.getDoubleByteArray(hostNO)[0];
		command[4]= CommonUtil.getDoubleByteArray(hostNO)[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(volume);
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getChannel2No());
		command[11]=CommonUtil.getSingleByte(spUitl.getChannel3No());
		command[12]=CommonUtil.getSingleByte(spUitl.getChannel4No());
		command[13]=CommonUtil.getSingleByte(spUitl.getChannel5No());
		command[14]=CommonUtil.getSingleByte(spUitl.getChannel6No());
		command[15]=CommonUtil.getSingleByte(spUitl.getChannel7No());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("===open audo==="+CommonUtil.bytesToHexString(command));
	}

	/**
	 *
	 * @Description: 打开音频模块（打开人工讲解）
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:29:02
	 * @update (20150929)
	 * @upcontent 更改协议      AA 55 10 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 EQ1 EQ2 EQ3 EQ4 EQ5 800M功率 OR
	 */
	public void openAudio() {
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x10 ;
		command[3]= hostNumberH;
		command[4]= hostNumberL;
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]=volumeByte;
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(spUitl.get800MPower());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("openAudio==打开人工讲解"+CommonUtil.bytesToHexString(command));
	}



	/**
	 *
	 * @Description: 设置设备的ID号码
	 * @param deviceNo  设备的ID号
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:31:04
	 * @update (20150929)
	 * 更新内容 AA 55 13 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 EQ1 EQ2 EQ3 EQ4 EQ5 800M功率 OR
	 */
	public void setDeviceID(int deviceNo){

		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x13 ;
		command[3]= hostNumberH;
		command[4]= hostNumberL;
		command[5]=CommonUtil.getDoubleByteArray(deviceNo)[0];
		command[6]=CommonUtil.getDoubleByteArray(deviceNo)[1];
		command[7]= volumeByte;
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(spUitl.get800MPower());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("setDeviceID=="+CommonUtil.bytesToHexString(command));

	}

	/**
	 *
	 * @Description: 频道设置
	 * @param channel0Byte  主机频道
	 * @param channel1Byte  辅助频道1
	 * @param channel2Byte  辅助频道2
	 * @param channel3Byte  辅助频道3
	 * @param channel4Byte  辅助频道4
	 * @param channel5Byte  辅助频道5
	 * @param channel6Byte  辅助频道6
	 * @param channel7Byte  辅助频道7
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:32:22
	 * @update (date)
	 */

	public void setDeviceChannel(int channel0Byte,int channel1Byte,int channel2Byte,int channel3Byte,int channel4Byte,int channel5Byte,int channel6Byte,int channel7Byte){

		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x12 ;
		command[3]= hostNumberH;
		command[4]= hostNumberL;
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= volumeByte;
		command[8]=CommonUtil.getSingleByte(channel0Byte);
		command[9]=CommonUtil.getSingleByte(channel1Byte);
		command[10]=CommonUtil.getSingleByte(channel2Byte);
		command[11]=CommonUtil.getSingleByte(channel3Byte);
		command[12]=CommonUtil.getSingleByte(channel4Byte);
		command[13]=CommonUtil.getSingleByte(channel5Byte);
		command[14]=CommonUtil.getSingleByte(channel6Byte);
		command[15]=CommonUtil.getSingleByte(channel7Byte);
		command[16]=(byte) (  command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("setDeviceChannel=="+CommonUtil.bytesToHexString(command));

	}
	/**
	 *
	 * @Description: 设置主频道
	 * @param mainChannel
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-9-29 上午9:36:25
	 * @update (date)
	 */
	public void setMainChannel(int mainChannel){

		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x12 ;
		command[3]= hostNumberH;
		command[4]= hostNumberL;
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= volumeByte;
		command[8]=CommonUtil.getSingleByte(mainChannel);
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(spUitl.get800MPower());
		command[16]=(byte) (  command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("setDeviceChannel=="+CommonUtil.bytesToHexString(command));

	}


	/**
	 *
	 * @Description: 主机占用（逻辑群组）
	 * @param hostChannel
	 * @param volumeByte
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:38:11
	 * @update (date)
	 */

	public  void openHostChannel(int hostChannel ,int volumeByte) {
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x20 ;
		command[3]= CommonUtil.getDoubleByteArray(hostChannel)[0];
		command[4]= CommonUtil.getDoubleByteArray(hostChannel)[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(volumeByte);
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getChannel2No());
		command[11]=CommonUtil.getSingleByte(spUitl.getChannel3No());
		command[12]=CommonUtil.getSingleByte(spUitl.getChannel4No());
		command[13]=CommonUtil.getSingleByte(spUitl.getChannel5No());
		command[14]=CommonUtil.getSingleByte(spUitl.getChannel6No());
		command[15]=CommonUtil.getSingleByte(spUitl.getChannel7No());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("openHostChannel==占用通道"+CommonUtil.bytesToHexString(command));

	}

	/**
	 *
	 * @Description: 释放主机（逻辑群组）
	 * @param hostChannel  主机编号（逻辑群组编号）
	 * @param volumeByte   音量
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:35:29
	 * @update (date)
	 */

	public  void closeHostChannel(int hostChannel ,int volumeByte) {

		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x22 ;
		command[3]= CommonUtil.getDoubleByteArray(hostChannel)[0];
		command[4]= CommonUtil.getDoubleByteArray(hostChannel)[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(volumeByte);
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getChannel2No());
		command[11]=CommonUtil.getSingleByte(spUitl.getChannel3No());
		command[12]=CommonUtil.getSingleByte(spUitl.getChannel4No());
		command[13]=CommonUtil.getSingleByte(spUitl.getChannel5No());
		command[14]=CommonUtil.getSingleByte(spUitl.getChannel6No());
		command[15]=CommonUtil.getSingleByte(spUitl.getChannel7No());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("closeHostChannel==通道释放"+CommonUtil.bytesToHexString(command));

	}


	/**
	 *
	 * @Description:关闭音频模块(关闭通信)
	 * @param lastHost 上一个主机的编号
	 * @param volume  当前音量
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:29:35
	 * @update (20150929)
	 * @updata 内容   AA 55 11 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 EQ1 EQ2 EQ3 EQ4 EQ5 800M功率 OR
	 */
	public void closeAudio(int lastHost,int volume) {
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x11 ;
		command[3]= CommonUtil.getDoubleByteArray(lastHost)[0];
		command[4]= CommonUtil.getDoubleByteArray(lastHost)[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(volume);
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(spUitl.get800MPower());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("closeAudio=="+CommonUtil.bytesToHexString(command));
	}



	/**
	 *
	 * @Description: 控制器关机(设备关闭时候发送该条指令)
	 * @param hostNo 主机编号（逻辑群组编号）
	 * @param volume
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-6-11 下午3:40:37
	 * @update (date)
	 */
	public  void closeCtrol(int  hostNo ,int volume) {
//		closeHostChannel(hostNo,volumeByte);
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x21 ;
		command[3]= CommonUtil.getDoubleByteArray(hostNo)[0];
		command[4]= CommonUtil.getDoubleByteArray(hostNo)[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(volume);
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getChannel2No());
		command[11]=CommonUtil.getSingleByte(spUitl.getChannel3No());
		command[12]=CommonUtil.getSingleByte(spUitl.getChannel4No());
		command[13]=CommonUtil.getSingleByte(spUitl.getChannel5No());
		command[14]=CommonUtil.getSingleByte(spUitl.getChannel6No());
		command[15]=CommonUtil.getSingleByte(spUitl.getChannel7No());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("closeCtrol==控制器关机"+CommonUtil.bytesToHexString(command));

	}


//	800M功率设置
//    AA 55 14 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 辅频道2 辅频道3 辅频道4 辅频道5 辅频道6 800M功率 OR
//数传功率设置
//    AA 55 15 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 辅频道2 辅频道3 辅频道4 辅频道5 辅频道6 数传功率 OR
//ID匹配进
//    AA 55 16 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 辅频道2 辅频道3 辅频道4 辅频道5 辅频道6 数传功率 OR
//ID匹配出
//    AA 55 17 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 辅频道2 辅频道3 辅频道4 辅频道5 辅频道6 数传功率 OR
	/**
	 * @Description:   AA 55 14 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 EQ1 EQ2 EQ3 EQ4 EQ5 800M功率 OR
	 * @param power800M
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-9-29 上午9:38:50
	 * @update (date)
	 */
	public  void  set800Power(int power800M){
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x14;
		command[3]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[0];
		command[4]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(spUitl.getChannelVolume());
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(power800M);
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("set800Power==控制器设置800M功率"+CommonUtil.bytesToHexString(command));
	}

	/**
	 *  AA 55 15 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 EQ1 EQ2 EQ3 EQ4 EQ5 数传功率 OR
	 * @Description: TODO
	 * @param powerShuChuan
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-9-29 上午9:39:24
	 * @update (date)
	 */
	public void setShuChuanPower(int powerShuChuan) {
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x15;
		command[3]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[0];
		command[4]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(spUitl.getChannelVolume());
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(powerShuChuan);
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("setShuChuanPower==控制器设置数传功率"+CommonUtil.bytesToHexString(command));
	}
	/**
	 *
	 * @Description: ID匹配进 AA 55 16 主机高 主机低 ID高 ID低 音量 控制器频道 辅频道1 EQ1 EQ2 EQ3 EQ4 EQ5 800M功率 OR
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-9-12 上午10:10:45
	 * @update (date)
	 */
	public void setIDMatchingIn(){
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x16;
		command[3]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[0];
		command[4]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(spUitl.getChannelVolume());
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(spUitl.get800MPower());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("setIDMatchingIn==控制器ID匹配进"+CommonUtil.bytesToHexString(command));
	}

	/**
	 *
	 * @Description: ID匹配出
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-9-12 上午10:13:21
	 * @update (date)
	 */
	public void setIDMatchingOut(){
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]=(byte) 0x17;
		command[3]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[0];
		command[4]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(spUitl.getChannelVolume());
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(spUitl.get800MPower());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("setIDMatchingOut==控制器ID匹配出"+CommonUtil.bytesToHexString(command));
	}



	/**
	 * @Description: 设置EQ
	 * @return void
	 * @throws
	 * @autour wzq
	 * @date 2015-9-12 上午10:13:21
	 * @update (date)
	 */
	public void setEQ(byte eqKind){
		byte[] command = new byte[17];
		command[0]=(byte) 0xAA;
		command[1]=(byte) 0x55;
		command[2]= eqKind;
		command[3]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[0];
		command[4]= CommonUtil.getDoubleByteArray(spUitl.getHostNo())[1];
		command[5]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[0];
		command[6]=CommonUtil.getDoubleByteArray(spUitl.getDeviceId())[1];
		command[7]= CommonUtil.getSingleByte(spUitl.getChannelVolume());
		command[8]=CommonUtil.getSingleByte(spUitl.getChannel0No());
		command[9]=CommonUtil.getSingleByte(spUitl.getChannel1No());
		command[10]=CommonUtil.getSingleByte(spUitl.getEQ1());
		command[11]=CommonUtil.getSingleByte(spUitl.getEQ2());
		command[12]=CommonUtil.getSingleByte(spUitl.getEQ3());
		command[13]=CommonUtil.getSingleByte(spUitl.getEQ4());
		command[14]=CommonUtil.getSingleByte(spUitl.getEQ5());
		command[15]=CommonUtil.getSingleByte(spUitl.get800MPower());
		command[16]=(byte) (command[3] ^ command[4]^ command[5]^ command[6]^ command[7]^ command[8]
				^ command[9]^ command[10]^ command[11]^ command[12]^ command[13]^ command[14]^ command[15]);
		try {
			stcOutputStream.write(command);
		} catch (IOException e) {
			e.printStackTrace();
		}
//		KJLoger.debug("setEQt==控制器EQ设置"+CommonUtil.bytesToHexString(command));
	}




}
